<link rel="stylesheet" href="../css/frame1.css?v=1.0.1">
<div id="view" v-cloak>
    <!-- 个人广播 -->
    <ul class="wrap">
        <div v-for="(m, index) in ffList" @click="_url({id:m.dy_id, url:'frame1/dy_detail', title:'详情'})">
            <li class="list">
                <div class="flex-bt" style="align-items:flex-start;">
                    <div class="left flex">
                        <div class="tx flex-c img-h" @click.stop @click="go_userInfo(m.id, m.name, m.sex)">
                            <img :src="imgurl+m.head_100" @load="imgCss(imgurl+m.head_100, $event)"
                                onerror="this.onerror=null;this.src='../image/touxiang.png'" alt="">
                            <i class="base-icon dy-male-icon" v-if="m.sex == '男'"></i>
                            <i class="base-icon dy-female-icon" v-if="m.sex == '女'"></i>
                        </div>
                        <div>
                            <div class="name-wrap flex">
                                <span class="name">{{m.name}}</span>
                                <span v-if="m.nvshen == 1" class="girl-tag tag"></span>
                                <span v-if="m.is_identity_authentication == 2" class="real-tag tag"></span>
                                <span v-if="m.is_vip >0" class="vip-tag tag"></span>
                                <!-- <i v-if="m.is_vip >0" class="base-icon dy-vip-icon" style="width: 25px;"></i>
                                    <i v-if="m.is_identity_authentication >0 && m.sex != '女'" class="base-icon dy-real-icon" style="width: 32px;"></i>
                                    <i v-if="m.is_identity_authentication >0 && m.sex == '女'" class="base-icon dy-girl-icon" style="width: 32px;"></i> -->
                            </div>
                            <span class="time">{{m.addtime}}</span>
                        </div>
                    </div>
                    <!-- <div class="more flex-c" @click.stop="more(m.dy_id);">
                            <i class="aui-iconfont aui-icon-more"></i>
                        </div> -->
                </div>
                <div class="dy-content-wrap new-padding-10">
                    <div class="tri"></div>
                    <ul class="ul">
                        <li class="li">
                            <i class="base-icon dy-theme-icon"></i>
                            <div class="dy-content">{{themeObj[m.category_id]}}</div>
                        </li>
                        <li class="li" v-if="m.datetime">
                            <i class="base-icon dy-time-icon"></i>
                            <div class="dy-content">{{m.datetime}}</div>
                        </li>
                        <li class="li" v-if="m.call">
                            <i class="base-icon dy-person-icon"></i>
                            <div class="dy-content">{{m.call}}</div>
                        </li>
                        <li class="li" v-if="m.filter">
                            <i class="base-icon dy-money-icon"></i>
                            <div class="dy-content" v-if="m.filter != '不限'">￥{{m.filter}}</div>
                            <div class="dy-content" v-else>{{m.filter}}</div>
                        </li>
                        <li class="li" v-if="m.citys">
                            <i class="base-icon dy-area-icon"></i>
                            <div class="dy-content">{{m.citys}}</div>
                        </li>
                        <li class="li" v-if="m.content">
                            <i class="base-icon dy-content-icon"></i>
                            <div class="dy-content">{{m.content}}</div>
                        </li>
                    </ul>
                    <div class="img-wrap flex-w" v-if="m.sumbImage && m.sumbImage.length > 0 && m.sumbImage[0]">
                        <div class="img img-h" v-for="(s, sindex) in m.sumbImage" @click.stop
                            @click="_url({imgArr:m.masterimg, iIndex:sindex, url: 'frame1/dy_img', title: '查看图片'})">
                            <img :src="imgurl+s" @load="imgCss(imgurl+s, $event)"
                                onerror="this.onerror=null;this.src='../image/error-img.png'" alt="">
                        </div>
                    </div>
                </div>
                <div class="footer">
                    <ul class="ul flex-a">
                        <li class="li" @click.stop @click="zan(m.dy_id, index)">
                            <i class="base-icon dy-nozan-icon" :class="{'dy-zan-icon':m.isthumbsup == 1}"></i>
                            <span>{{ m.num }}</span>
                        </li>
                        <!-- <li class="li" v-if="m.id != myuserid" @click.stop @click="addComment(m.dy_id, m.id)">
                            <i class="base-icon dy-comment-icon"></i>
                            <span>评论</span>
                        </li> -->
                        <li class="li" >
                            <i class="base-icon dy-comment-icon"></i>
                            <span>评论</span>
                        </li>
                        <li class="li" v-if="myuserid != m.id && m.type == 1" @click.stop
                            @click="joinEnroll(m.dy_id, index)">
                            <i class="base-icon dy-nobaoming-icon" :class="{'dy-baoming-icon':m.self_enroll == 1}"></i>
                            <span v-if="m.self_enroll == 0">我要报名({{m.enroll}})</span>
                            <span v-if="m.self_enroll == 1" style="color: #673AB7;">取消报名({{m.enroll}})</span>
                        </li>
                        <li class="li" v-if="myuserid == m.id  && m.type == 1">
                            <i class="base-icon dy-nobaoming-icon"></i>
                            <span>报名人数({{m.enroll}})</span>
                        </li>
                    </ul>
                </div>
                <div class="over" v-if="m.overdue == 1"></div>
            </li>
            <!-- 
                <div class="zan-wrap w-bg flex-bt new-margin-tb-10 new-padding-10"
                    v-if="m.zan && m.zan.length > 0">
                    <div class="flex">
                        <i class="base-icon dy-zan-icon"></i>
                        <ul class="tx-ul flex">
                            <li class="li" v-for="(z, zindex) in m.zan" v-if="index<3">
                                <div class="img img-h">
                                    <img :src="imgurl+z.head_100" @load="imgCss(imgurl+z.head_100, $event)" onerror="this.onerror=null;this.src='../image/touxiang.png'" alt="">
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="theme-font">共{{m.zan.length}}人点赞</div>
                </div>
                <div class="comment-wrap w-bg new-margin-tb-10 new-padding-10" v-if="m.text && m.text.length > 0">
                    <ul class="c-ul">
                        <li class="li" v-for="(t, tindex) in m.text">
                            <div class="flex-bt" style="align-items:flex-start;">
                                <div class="left flex">
                                    <div class="tx img-h">
                                        <img :src="imgurl+t.head_100" @load="imgCss(imgurl+t.head_100, $event)"
                                            onerror="this.onerror=null;this.src='../image/touxiang.png'" alt="">
                                    </div>
                                    <div>
                                        <div class="name-wrap flex-c">
                                            <span class="name">{{ t.name }}</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="dy-content-wrap new-padding-10">
                                <div class="tri"></div>
                                <div class="c-content theme-font">
                                    {{t.text}}
                                </div>
                            </div>
                        </li>
                    </ul>
                </div> -->
        </div>
        <div id="no_more"></div>
    </ul>
    <div class="input-bg new-hide">
        <div class="input-wrap">
            <input type="text" placeholder="说点什么">
            <button class="send-btn" @click.stop="send()">发送</button>
        </div>
    </div>
</div>
<script>
    var view = new Vue({
        el: '#view',
        data: {
            myuserid: myuserid,
            imgurl: imgurl,
            ffList: [],
            ffInfo: {},
            inputObj: {
                id: 0,
                uid: 0
            }, // 评论 广播id
        },
        methods: {
            // 约会报名
            joinEnroll: function (id, index) {
                var _this = this;
                var status = _this.ffList[index].self_enroll;
                var url = status == 0 ? 'home/Dymanic/enroll' : 'home/Dymanic/cancelenroll';
                _ajax(url, function (ret, err) {
                    _log(JSON.stringify(ret))
                    if (ret) {
                        _msg(ret.msg);
                        if (ret.code == 200) {
                            _this.ffList[index].self_enroll = status == 0 ? 1 : 0;
                            _this.ffList[index].enroll = status == 0 ? parseInt(_this.ffList[index] .enroll) + 1 : _this.ffList[index].enroll - 1;
                            pushMsg(_this.ffList[index].id)
                        } else if (ret.code == 220) {
                            _url({
                                url: 'frame4',
                                title: '开通会员'
                            })
                        }
                    }
                }, {
                    user_id: myuserid,
                    dy_id: id,
                })
            },
            // 点赞
            zan: function (id, index, type) {
                var _this = this;
                var status = _this.ffList[index].isthumbsup;
                _ajax('home/Dymanic/thumbsup', function (ret, err) {
                    _log(JSON.stringify(ret))
                    _log(JSON.stringify(err))
                    if (ret) {
                        _msg(ret.msg);
                        if (ret.code == 200) {
                            _this.ffList[index].isthumbsup = status == 0 ? 1 : 0;
                            _this.ffList[index].num = status == 0 ? parseInt(_this.ffList[index] .num) + 1 : _this.ffList[index].num - 1;
                            pushMsg(_this.ffList[index].id);
                        }
                    }
                }, {
                    type: parseInt(status) + 1,
                    dy_id: id,
                    userid: myuserid,
                })
            },
            // 评论
            addComment: function (dy_id, uid) {
                $('.input-bg').removeClass('new-hide');
                view.inputObj = {
                    id: dy_id,
                    uid: uid
                };
                $('.input-bg input').focus();
            },
            // 发布评论
            send: function () {
                var _this = this;
                var val = $.trim($('.input-wrap input').val());
                if (!val) {
                    _msg('评论不能为空');
                    return;
                }
                _ajax('home/Dymanic/comment', function (ret, err) {
                    if (ret) {
                        _msg(ret.msg);
                        if (ret.code == 200) {
                            $('.input-wrap input').val('');
                            $('.input-bg').addClass('new-hide');
                            pushMsg(_this.inputObj.uid);
                        }
                    }
                }, {
                    dy_id: _this.inputObj.id,
                    userid: myuserid,
                    touserid: _this.inputObj.uid,
                    type: 0, //0为评论，1为回复
                    content: val,
                })
            },
            _url: function (param, url) {
                _url(param, url);
            },
            // 图片自适应
            imgCss: function (url, event) {
                _log(url)
                var e = event.currentTarget;
                imgCss(url, function (w, h) {
                    if (w < h) {
                        $(e).parent().addClass('img-w').removeClass('img-h');
                    }
                })
            },
            // 查看用户资料
            go_userInfo: function (id, name, sex) {
                go_userInfo(id, name, sex)
            },
            // 清除html
            clearHtml: function (s) {
                return clearHtml(s);
            }

        }
    })
    pageParam = getParam();
    var userid = pageParam['uid'];
    judgeLogin()
    getData(0);
    _scrollToBottom(function () {
        if (heigutgao == 1) {
            pagenum++;
            getData(pagenum)
        }
    })

    // 隐藏输入框
    $('.input-bg input').on('blur', function () {
        $('.input-bg').addClass('new-hide');
    })

    // 获取数据
    function getData(page) {
        var url = userid ? 'home/Dymanic/otherlist' : 'home/Dymanic/selflist';
        userid = userid ? userid : myuserid;
        var param = {
            userid: userid,
            to_user: myuserid,
        }
        var loading = page == 0 ? 1 : 0;
        _lists(url, page, loading, param)
    }
</script>

</html>